package com.yunfei.core.utils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.ui.Model;

/**
 *
 * 前端处理工具类
 * @author zhengyunfei
 *
 */
public class FmUtils {

	private static final String IMAGEPATH = "/resources/static/imgs";
	private static final String CSSPATH = "/resources/static/css";
	private static final String SCRIPTSPATH = "/resources/static/js";


	/*
	 * 相应处理，添加base,csspath,scriptspath路径，供前端模版使用
	 */
	public static void FmData(HttpServletRequest request, Model model) {

		Object o = request.getAttribute("site");

		Site site = null;

		if (o != null && o instanceof Site)
		{
			site = (Site) o;
		}

		if (model != null && site != null)
		{
			model.addAttribute("base", site.getContextPath());
			model.addAttribute("imgs", site.getContextPath() + IMAGEPATH);
			model.addAttribute("css", site.getContextPath() + CSSPATH);
			model.addAttribute("js", site.getContextPath() + SCRIPTSPATH);
			model.addAttribute("basePath", site.getHttpUrIAddr());
		}
	}



}
